import 'package:flutter/material.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:guochaoapp/common/theme.dart';
import 'package:guochaoapp/config/config.dart';
import 'package:guochaoapp/config/container.dart';
import 'package:logging/logging.dart';
import 'package:get/get.dart';
import './routes/app_pages.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

void main() => FlutterBugly.postCatchedException(() async {
  GCConfig.env = Env.DEV;

  WidgetsFlutterBinding.ensureInitialized();

  FlutterBugly.init(androidAppId: "b5065a801d", iOSAppId: "da85a281ff", autoCheckUpgrade: true).then((_result) {
    print(_result.message);
  });

  final config = GCConfig(
      debug: false, loggerLevel: Level.OFF, theme: GCTheme.defaultTheme);
  final container = GCContainer(config);
  await container.onReady;

  EasyLoading.instance
    ..displayDuration = const Duration(milliseconds: 2000)
    ..indicatorType = EasyLoadingIndicatorType.fadingCircle
    ..loadingStyle = EasyLoadingStyle.dark
    ..indicatorSize = 45.0
    ..radius = 10.0
    ..progressColor = Colors.yellow
    ..backgroundColor = Colors.green
    ..indicatorColor = Colors.yellow
    ..textColor = Colors.yellow
    ..maskColor = Colors.blue.withOpacity(0.5)
    ..userInteractions = true
    ..dismissOnTap = false;

  runApp(GetMaterialApp(
    theme: config.theme,
    getPages: AppPages.pageList,
    initialRoute: Routes.INITIAL,
    builder: EasyLoading.init(),
  ));
});
